package jrain.fw.script.expression;

public class BooleanLiteral extends Literal {
	// -------------------------------------
	// Member variables
	// -------------------------------------

	public static final BooleanLiteral TRUE = new BooleanLiteral("true");
	public static final BooleanLiteral FALSE = new BooleanLiteral("false");

	// -------------------------------------

	/**
	 * Constructor
	 */
	public BooleanLiteral(String pToken) {
		super(getValueFromToken(pToken));
	}

	// -------------------------------------

	/**
	 * Parses the given token into the literal value
	 */
	static Object getValueFromToken(String pToken) {
		return ("true".equals(pToken)) ? Boolean.TRUE : Boolean.FALSE;
	}

	// -------------------------------------
	// Expression methods
	// -------------------------------------

	/**
	 * Returns the expression in the expression language syntax
	 */
	public String getExpressionString() {
		return (getValue() == Boolean.TRUE) ? "true" : "false";
	}

	// -------------------------------------
}
